package com.awardsystem.entity;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(value = AuditingEntityListener.class)
public abstract class BaseTime {
     /**
     * 所有类的超类
     * 自动更新创建时间和更新时间
     * * **/
     @CreatedDate
     @Column(nullable = false, updatable = false)
     private LocalDateTime createTime;

     @LastModifiedDate
     @Column()
     private LocalDateTime updateTime;

     public LocalDateTime getCreateTime() {
          return createTime;
     }

     public void setCreateTime(LocalDateTime createTime) {
          this.createTime = createTime;
     }

     public LocalDateTime getUpdateTime() {
          return updateTime;
     }

     public void setUpdateTime(LocalDateTime updateTime) {
          this.updateTime = updateTime;
     }

     @Override
     public String toString() {
          return "BaseTime{" +
                  "createTime=" + createTime +
                  ", updateTime=" + updateTime +
                  '}';
     }

}
